﻿@using ZX.Tools
@using ZX.Model
@model MyGiftBuy
@{
    Sys_UserModel user = ViewBag.User;
    List<MyGiftBuyDetail> listDetail = ViewBag.ListDetail ?? new List<MyGiftBuyDetail>();
    List<Sys_User> userList = ViewBag.UserList ?? new List<Sys_User>();
    string userSign0 = "";
    string userSign1 = "";
    string userSign2 = "";

}
<link href="~/Static/styles/bootstrap.min.css" rel="stylesheet" />
<link href="~/Static/js/layui/css/layui.css" rel="stylesheet" />
<script src="/Static/js/jquery/jquery-1.11.1.min.js"></script>
<script src="~/Static/js/layui/layui.js"></script>
<div class='row page-content'>
    <div class='panel'>
        <div class='panel-heading'><strong><i class='icon-building'></i>物资采购审批单</strong></div>
        <div class='panel-body'>
            <form action="/MyGiftBuy/SaveApproval" method="post" class="form" id="formMyGiftBuy">
                <input type="hidden" name="Id" value="@Model.Id" />
                <input type="hidden" name="status" value="@ApplyStatus.驳回.ToInt()" />
                <input type="hidden" name="deptId" value="@user.Fk_DeptId" />
                <table class='table table-bordered' style="border: 1px solid #ddd;">
                    <tr>
                        <th class="text-left" colspan="3">申请人：@user.RealName</th>
                        <th class='text-left' colspan="2">申请部门/公司： @user.DeptName</th>
                        <th class='text-left' colspan="2">日期：@(Model.AddTime.ToDateFormat("yyyy-MM-dd"))</th>
                    </tr>
                    <tr>
                        <th class="text-center">姓名</th>
                        <th class="text-center">品牌及型号</th>
                        <th class="text-center">数量</th>
                        <th class="text-center">单价（元）</th>
                        <th class="text-center w-100px">金额（元）</th>
                        <th class="text-center">购置部门</th>
                        <th class="text-center">资产类别</th>
                    </tr>
                    @foreach (var item in listDetail)
                    {
                        <tr>
                            <td>@item.Name</td>
                            <td>@item.Brand</td>
                            <td>@(item.Count + item.GifUnitName)</td>
                            <td>@item.Price</td>
                            <td name="moneys">@(item.Count * item.Price)</td>
                            <td>@item.BuyDeptName</td>
                            <td>@item.ZChanType</td>
                        </tr>
                    }
                    <tr>
                        <th class="text-center" colspan="4">总计金额</th>
                        <td colspan="3">
                            <span id="spmoney">@(listDetail.Sum(t => t.Price * t.Count))(元)</span>
                        </td>
                    </tr>
                    <tr>
                        <th class="text-center">申请理由</th>
                        <td colspan="6">@Model.ADesc</td>
                    </tr>
                    <tr>
                        <td rowspan="3" class="text-center"><strong>审批人</strong></td>
                        <th class="text-center w-120px">部门/公司负责人</th>
                        <td colspan="5" style="width:201px;height:51px;">
                            <div>
                                @{
                                    try
                                    {
                                        userSign0 = userList[0].USgin;
                                    }
                                    catch { }

                                    try
                                    {
                                        userSign1 = userList[1].USgin;
                                    }
                                    catch { }

                                    try
                                    {
                                        userSign2 = userList[2].USgin;
                                    }
                                    catch { }

                                    if (userSign2.IsNotNullOrEmpty())
                                    {
                                        <img src="@userSign2" style="width:200px;height:50px;margin-left:7px;" />
                                    }
                                }
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="text-center w-120px">综合管理部</th>
                        <td colspan="5" style="width:201px;height:51px;">
                            <div>
                                @{
                                    if (userSign1.IsNotNullOrEmpty())
                                    {
                                        <img src="@userSign1" style="width:200px;height:50px;margin-left:7px;" />
                                    }
                                }
                            </div>
                        </td>
                    </tr>
                    <tr>
                        <th class="text-center w-120px">总经理</th>
                        <td colspan="5" style="width:201px;height:51px;">
                            <div>
                                @{
                                    if (userSign0.IsNotNullOrEmpty())
                                    {
                                        <img src="@userSign0" style="width:200px;height:50px;margin-left:7px;" />
                                    }
                                }
                            </div>
                        </td>
                    </tr>
                </table>
            </form>
        </div>
    </div>
</div>
<script type="text/javascript">
    $(function () {
        onprint();
    });
    function printHtml(html) {
        var bodyHtml = html;
        document.body.innerHTML = html;
        window.print();
        document.body.innerHTML = bodyHtml;
    }
    function onprint() {
        var html = $(".panel-body").html();
        printHtml(html);
    }
</script>
